package com.example.demo.service.Impl;

import com.example.demo.ao.BulkAo;
import com.example.demo.mapper.BulkInfoMapper;
import com.example.demo.mapper.UploadMapper;
import com.example.demo.service.DownloadService;
import com.example.demo.vo.BulkUserVo;
import com.example.demo.vo.BulkVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DownloadServiceImpl implements DownloadService {


    @Autowired
    private BulkInfoMapper bulkInfoMapper;

    @Autowired
    private UploadMapper uploadMapper;

    @Override
    public List<BulkVo> downloadInfo(BulkAo bulkAo) {
        List<BulkVo> bulkInfoList = bulkInfoMapper.getBulkInfoList(bulkAo);
        return bulkInfoList;
    }


    public List<BulkUserVo> downloadUserInfo() {
        List<BulkUserVo> bulkUserList = bulkInfoMapper.getBulkUserList();
        for (BulkUserVo bulkUserVo : bulkUserList) {
            if ("65401".equals(bulkUserVo.getMgtOrgCode())){
                bulkUserVo.setType("乌鲁木齐");
            }else {
                bulkUserVo.setType("其他");
            }
        }
        return bulkUserList;
    }



    public int insertTests(List<BulkUserVo> bulkUserVos) {
        int count = 0;
        for (BulkUserVo test : bulkUserVos) {
            count += uploadMapper.insertTests(test);
        }
        return count;
    }

}
